package android.magical;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper
{
	
	private static final String DATABASE_NAME = "magicalDB";
	private static final int DATABASE_VERSION = 8;
	private static final String DATABASE_CREATE = "CREATE TABLE magicalevent ("+
			"_id integer PRIMARY KEY AUTOINCREMENT,"+
			"owner TEXT NOT NULL,"+
			"date TEXT NOT NULL,"+
			"time TEXT NOT NULL,"+
			"message TEXT NOT NULL"+
			");";

	public DatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DATABASE_CREATE);


	}
	
	public ContentValues addTestItem(String owner, String date, String time, String message){
        ContentValues values = new ContentValues();
		values.put(DatabaseControl.KEY_OWNER, owner);
		values.put(DatabaseControl.KEY_DATE, date);
		values.put(DatabaseControl.KEY_TIME, time);
		values.put(DatabaseControl.KEY_MESSAGE, message);
		return values;
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		
		db.execSQL("DROP TABLE IF EXISTS magicalevent");
		onCreate(db);
	}

}
